package com.didispace;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

// 通过直接注入的方式来使用消息通道对象，注入上面例子中 SinkSender 接口中定义的名为 input 的消息输入通道。  p358
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = HelloApplication.class)
@WebAppConfiguration
public class HelloApplicationTests2 {

    @Autowired
    private MessageChannel input;

    @Test
    public void contextLoads() {
        input.send(MessageBuilder.withPayload("From SinkSender").build());
    }
}

// 2023-03-01 21:23:59.924  INFO 34876 --- [           main] com.didispace.HelloApplication           : Received: From SinkSender